﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tbHOADON_THUPHI_DATA_RAW
/// </summary>
public class cls_tbHOADON_THUPHI_DATA_RAW
{
	public cls_tbHOADON_THUPHI_DATA_RAW()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    #region Insert từ thu phí
    public static string Insert_from_thuphi(DateTime NGAY, string F_MAHV, string MATHANG, decimal DOANHSOBANCHUACOTHUE, string GHICHU)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[5];
        para[0] = new SqlParameter("@NGAY", NGAY);
        para[1] = new SqlParameter("@F_MAHV", F_MAHV);
        para[2] = new SqlParameter("@MATHANG", MATHANG);
        para[3] = new SqlParameter("@DOANHSOBANCHUACOTHUE", DOANHSOBANCHUACOTHUE);
        para[4] = new SqlParameter("@GHICHU", GHICHU);
        
        try
        {
            connect.ExecuteQuery("tbHOADON_THUPHI_DATA_RAW_INSERT_from_thuphi", para);
            return "OK";
        }
        catch
        { return "ERR"; }
    }
    #endregion

    #region select 
    public static DataTable GetAll()
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
                
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_THUPHI_DATA_RAW_GetAll", null);
        }
        catch { }
        return dt;
    }
    #endregion

    #region Update
    public static string Update_chuyensanghoadon(int ID)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { ID };
        string[] parameters = { "@ID" };

        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }

        try
        {
            connect.ExecuteQuery("tbHOADON_THUPHI_DATA_RAW_Update_To_HoaDon_temp", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion
}